#!/bin/bash
#
# Deployment (to Poly repo)
#
# Usage:
#   ./release.sh <function name>

copy-with-stamp() {
  test $# -eq 3 || die "Usage: copy-with-stamp \$stamp \$src \$dest"

  local filename=$(basename $2)

  echo "$2 -> $3"
  sed "s|%Id%|$filename - $1|" $2 > $3
}

deploy() {
  local stamp=$(hg parent --template "r{rev} - {date|date}")

  # dependency of pgi.py
  copy-with-stamp "$stamp" python/tnet.py ../polyweb/pgi_lib/tnet.py

  # dependency of poly server
  copy-with-stamp "$stamp" python/tnet.py ../polyweb/deps/tnet.py

  # dependency of pgi.R
  copy-with-stamp "$stamp" R/tnet.R ../polyweb/pgi_lib/tnet.R

  # dependency of hogR
  copy-with-stamp "$stamp" R/tnet.R ../polyweb/hogR/R/tnet.R
}

"$@"
